package day06;

import java.util.Scanner;

public class Normal2 {
    public static void main(String[] args) {
        System.out.println("感谢**的表演，下面请打分");
        System.out.println("几个人评分");
        int num=new Scanner(System.in).nextInt();
        System.out.println("平均数是"+calAvg(inputScores(num)));
    }
    public static double[] inputScores(int n){
        Scanner sc=new Scanner(System.in);
        double[] arr=new double[n];
        for (int i = 0; i < n; i++) {
            System.out.println("请打分");
            arr[i]=sc.nextDouble();
        }
        return arr;
    }
    public static double calAvg(double[] arr){
        double avg=0;
        double sum=0;
        double max=arr[0];
        double min=arr[0];
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
            if (max<arr[i]){
                max=arr[i];
            }
            if (min>arr[i]){
                min=arr[i];
            }
        }
        avg=(sum-max-min)/(arr.length-2);
        return avg;
    }
}
